<template>
  <div class="config">
    <div class="titles"><p>就业信息管理</p></div>
    <!-- 按钮 -->
    <div class="btns">
      <el-button size="small" type="primary" @click="toAdd">添加</el-button>
    </div>
 
    <!-- 表格 -->
    <el-table :data="list" style="width: 100%" size="small">
      <el-table-column type="index" label="序号"> </el-table-column>
      <el-table-column prop="key" label="专业名称" width="180"> </el-table-column>
      <el-table-column prop="val" label="就业方向"> </el-table-column>
      <el-table-column label="操作" width="150" align="center"> 
        <template v-slot="scope">
          <el-button size="small" type="danger" @click="del(scope.row)">删除</el-button>
          <el-button size="small" type="primary" @click="edit(scope.row)">修改</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 模态框 -->
    <el-dialog
      class="customer_modal"
      title="添加Config"
      :visible.sync="dialogVisible"
      width="60%">
      {{form}}
      <el-form :model="form" label-width="100px">
        
        <el-form-item label="专业名称" >
          <el-input v-model="form.key"></el-input>
        </el-form-item>
        <el-form-item label="就业方向">
          <el-input v-model="form.val"></el-input>
        </el-form-item>
        
      </el-form>
      
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="small">取 消</el-button>
        <el-button type="primary" @click="save" size="small">确 定</el-button>
      </span>
    </el-dialog>


     <!-- 带图 -->
     <el-row>
  <el-col :span="120" v-for="(o, index) in 1" :key="o" :offset="index > 0 ? 3: 0">
    <el-card :body-style="{ padding: '0px' }">
       <img src="https://img-u-1.51miz.com/Photo/2017/06/08/10/P435047_9e80016304724b2b4eb2c434dd949422.jpg!/quality/90/unsharp/true/compress/true/format/webp/fh/260" class="image">
       <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1593895850528&di=a373644c8294a3975a510e81eac609b3&imgtype=0&src=http%3A%2F%2Fimg1.imgtn.bdimg.com%2Fit%2Fu%3D148688711%2C395119814%26fm%3D214%26gp%3D0.jpg" class="image">
      
      
      <div style="padding: 14px;">
        <span>就业信息</span>
        <div class="bottom clearfix">
          <time class="time">{{ currentDate }}</time>
       
        </div>
      </div>
    </el-card>
  </el-col>
</el-row>

    
  </div>
</template>

<style lang="css" scoped>
</style>


<style scoped>
.titles{
  float: left;
  margin: 0 auto;
  padding-left: 15px;
}

.titles p{
  font-size: 16px;
	color: #fff;
}

.config{
  background-color: #f3ae48;
  border-radius: 5px;
  height: 45px;
}

.btns{
  float: right;
  margin: 9px auto;
  padding-right: 10px;
}

.dialog{
  margin: auto;
  text-align: center;
  overflow: hidden;
  
}

</style>

<script>

// 导入request , 浏览器提供给我们的用于与后台进行交互的工具 api
import {get,post} from '@/utils/request'
export default {
  data (){
    return {
      form:{},
      list:[],
      dialogVisible:false
    }
  },
  created(){
    this.loadData();
  },
  methods:{
    // 保存
    save(){
      let url = "/config/saveOrUpdate"
      post(url,this.form).then( (response)=>{
        // 1. 模态框关闭
        this.dialogVisible = false;
        // 2. 提示
        this.$message({type:"success",message:response.message})
        // 3. 刷新
        this.loadData();
      } )
    },
    // 删除
    del(row){
      let url = "/config/deleteById"
      get(url,{id:row.id}).then((response)=>{
        // 1. 提示
        this.$message({type:"success",message:response.message})
        // 2. 刷新 
        this.loadData();
      } )
    },
    // 编辑
    edit(row){
      this.form = row;
      this.dialogVisible = true;
    },
    // 加载数据
    loadData(){
      let url = "/config/findAll";
      get(url).then((response)=>{
        // response就是后端返回给我们的Message{status,message,data,timestamp}
        this.list = response.data;
      } );
    },
    toAdd(){
      this.dialogVisible = true;
    }
  },

   return :{
        value: null
      }
}
</script>
